package com.project.common.domain.dto;

import com.project.common.domain.BaseVersionDO;
import com.project.common.domain.Convert;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;

/**
 * 转换类
 *
 */
@Slf4j
public class BaseAssembler extends Convert {
    /**
     * 转对象
     *
     * @param <T>
     * @return T
     */
    public <T> T convertTo(Class<T> t) {
        Assert.notNull(t, "参数不能为NULL");
        T r = Convert.getConvert().map(this, t);
        return r;
    }

    /**
     * 转Do
     *
     * @param t
     * @param <T>
     * @return
     */
    public <T extends BaseVersionDO> T convertToDo(Class<T> t) {
        Assert.notNull(t, "参数不能为NULL");
        return convertTo(t);
    }
}
